﻿<UserControl x:Class="TechNewLogic.GraphIT.Hv.Legend.TableLegend"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
		xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
		xmlns:Hv="clr-namespace:TechNewLogic.GraphIT.Hv"
		xmlns:ml="clr-namespace:TechNewLogic.GraphIT.MultiLanguage"
		xmlns:Legend="clr-namespace:TechNewLogic.GraphIT.Hv.Legend" mc:Ignorable="d"
		d:DesignHeight="300" d:DesignWidth="300" x:Name="root" SnapsToDevicePixels="True">

	<UserControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="/TechNewLogic.GraphIT;component/Styles/PopupButton.xaml" />
				<ResourceDictionary
						Source="/TechNewLogic.GraphIT;component/Styles/ScrollViewerStyle.xaml" />
			</ResourceDictionary.MergedDictionaries>

			<SolidColorBrush x:Key="backgroundBrush" Color="Black" />
			<SolidColorBrush x:Key="foregroundBrush" Color="WhiteSmoke" />

			<Style TargetType="ToggleButton" BasedOn="{StaticResource PopupButtonStyle}">
				<Setter Property="Margin" Value="5" />
				<Setter Property="Foreground" Value="{StaticResource foregroundBrush}" />
			</Style>

			<Style x:Key="GridViewColumnHeaderGripper" TargetType="Thumb">
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="{x:Type Thumb}">
							<Rectangle HorizontalAlignment="Center" Width="5" Fill="Transparent" />
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Style>

			<Style x:Key="GridViewColumnHeaderStyle" TargetType="GridViewColumnHeader">
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="GridViewColumnHeader">
							<!--<Border BorderBrush="Yellow" BorderThickness="1">-->
							<Grid Background="Transparent">
								<ContentPresenter Name="HeaderContent" TextElement.FontWeight="Bold"
										TextElement.Foreground="{StaticResource foregroundBrush}"
										Margin="5" VerticalAlignment="Center"
										HorizontalAlignment="Center" />
								<Thumb x:Name="PART_HeaderGripper" HorizontalAlignment="Right"
										DragDelta="ListView_DragDelta" Margin="0,0,-2.5,0"
										Style="{StaticResource GridViewColumnHeaderGripper}" />
							</Grid>
							<!--</Border>-->
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Style>

			<Style x:Key="ListViewItemContainerStyle" TargetType="ListViewItem">
				<Setter Property="HorizontalContentAlignment" Value="Stretch" />
				<Setter Property="VerticalContentAlignment" Value="Stretch" />
				<Setter Property="Foreground" Value="{StaticResource foregroundBrush}" />
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="{x:Type ListViewItem}">
							<GridViewRowPresenter Margin="0,-1,0,0" />
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Style>

			<Style x:Key="{x:Type Legend:TableCellControl}" TargetType="Legend:TableCellControl">
				<Setter Property="CellBackground" Value="{StaticResource backgroundBrush}" />
			</Style>

		</ResourceDictionary>
	</UserControl.Resources>

	<Grid DataContext="{Binding ViewModel, ElementName=root}"
			Background="{StaticResource backgroundBrush}">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition />
		</Grid.RowDefinitions>

		<StackPanel>
			<Rectangle Height="1" Fill="{StaticResource foregroundBrush}" />
			<StackPanel Orientation="Horizontal" Margin="0,5">
				<TextBlock Text="{x:Static ml:MlResources.SelectAggregates}"
						Foreground="{StaticResource foregroundBrush}" VerticalAlignment="Center"
						FontWeight="Bold" Margin="10,5" />
				<UniformGrid Columns="5">
					<ToggleButton Content="{x:Static ml:MlResources.DeltaY}"
							IsChecked="{Binding ShowDeltaYColumn}" />
					<ToggleButton Content="{x:Static ml:MlResources.DeltaT}"
							IsChecked="{Binding ShowDeltaTColumn}" />
					<ToggleButton Content="{x:Static ml:MlResources.Min}"
							IsChecked="{Binding ShowMinColumn}" />
					<ToggleButton Content="{x:Static ml:MlResources.Max}"
							IsChecked="{Binding ShowMaxColumn}" />
					<ToggleButton Content="{x:Static ml:MlResources.Avg}"
							IsChecked="{Binding ShowAvgColumn}" />
				</UniformGrid>
			</StackPanel>
			<Rectangle Height="1" Fill="{StaticResource foregroundBrush}" Opacity="0.5" />
		</StackPanel>

		<ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Hidden"
				Grid.Row="1">
			<ListView x:Name="listView" ItemsSource="{Binding Curves}" BorderThickness="0"
					Background="{StaticResource backgroundBrush}"
					ItemContainerStyle="{StaticResource ListViewItemContainerStyle}">

				<ListView.View>
					<Legend:ExtendedGridView x:Name="gridView" AllowsColumnReorder="False"
							ColumnHeaderContainerStyle="{StaticResource GridViewColumnHeaderStyle}">
						<GridViewColumn Legend:GridViewHelper.CanColumnResize="False">
							<GridViewColumn.CellTemplate>
								<DataTemplate>
									<Legend:TableCellControl>
										<Legend:TableCellControl.ControlContent>
											<Hv:CurveRectControl Curve="{Binding Curve}" />
										</Legend:TableCellControl.ControlContent>
									</Legend:TableCellControl>
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>
						<GridViewColumn Legend:GridViewHelper.HeaderID="d1"
								Legend:GridViewHelper.CanColumnResize="False">
							<GridViewColumn.CellTemplate>
								<DataTemplate>
									<Legend:TableCellControl Text="{Binding Description1}" />
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>
						<GridViewColumn Legend:GridViewHelper.HeaderID="d2"
								Legend:GridViewHelper.CanColumnResize="False">
							<GridViewColumn.CellTemplate>
								<DataTemplate>
									<Legend:TableCellControl Text="{Binding Description2}" />
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>
						<GridViewColumn Legend:GridViewHelper.HeaderID="d3"
								Legend:GridViewHelper.CanColumnResize="False">
							<GridViewColumn.CellTemplate>
								<DataTemplate>
									<Legend:TableCellControl Text="{Binding Description3}" />
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>
						<GridViewColumn Legend:GridViewHelper.HeaderID="d4"
								Legend:GridViewHelper.CanColumnResize="False">
							<GridViewColumn.CellTemplate>
								<DataTemplate>
									<Legend:TableCellControl Text="{Binding Description4}" />
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>
						<GridViewColumn Legend:GridViewHelper.HeaderID="d5"
								Legend:GridViewHelper.CanColumnResize="False">
							<GridViewColumn.CellTemplate>
								<DataTemplate>
									<Legend:TableCellControl Text="{Binding Description5}" />
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>
						<GridViewColumn Header="{x:Static ml:MlResources.Uom}"
								Legend:GridViewHelper.CanColumnResize="False">
							<GridViewColumn.CellTemplate>
								<DataTemplate>
									<Legend:TableCellControl Text="{Binding Uom}" />
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>
						<GridViewColumn Header="{x:Static ml:MlResources.From}"
								Legend:GridViewHelper.CanColumnResize="False">
							<GridViewColumn.CellTemplate>
								<DataTemplate>
									<Legend:TableCellControl Text="{Binding Min}" />
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>
						<GridViewColumn Header="{x:Static ml:MlResources.To}"
								Legend:GridViewHelper.CanColumnResize="False">
							<GridViewColumn.CellTemplate>
								<DataTemplate>
									<Legend:TableCellControl Text="{Binding Max}" />
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>
						<GridViewColumn Header="{x:Static ml:MlResources.Value}">
							<GridViewColumn.CellTemplate>
								<DataTemplate>
									<Legend:TableCellControl Text="{Binding CurrentValue}" />
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>
					</Legend:ExtendedGridView>
				</ListView.View>
			</ListView>
		</ScrollViewer>

	</Grid>

</UserControl>
